public class SignalList{
	public static Signal list, last;
	
	public static void SendSignal(int type, Proc dest, double arrtime){
	 	Signal newSignal = new Signal();
	 	newSignal.signalType = type;
	 	newSignal.destination = dest;
	 	newSignal.arrivalTime = arrtime;
	 	newSignal.totalArrivalTime = arrtime;
	 	newSignal.retrial = false;
	 	orderSignal(newSignal);	 	
 	
 }
	
	public static void SendSignal(int type, Proc dest, double arrtime, double totalArrivalTime, boolean retrial){
	 	Signal newSignal = new Signal();
	 	newSignal.signalType = type;
	 	newSignal.destination = dest;
	 	newSignal.arrivalTime = arrtime;
	 	newSignal.totalArrivalTime = totalArrivalTime;
	 	newSignal.retrial = retrial;
	 	orderSignal(newSignal);
	 }
	
	private static void orderSignal(Signal newSignal) {
	 	Signal dummy, predummy;

	 	predummy = list;
	 	dummy = list.next;
	 	while ((dummy.arrivalTime < newSignal.arrivalTime) & (dummy != last)){
	 		predummy = dummy;
	 		dummy = dummy.next;
	 	}
	 	predummy.next = newSignal;
	 	newSignal.next = dummy;
	}
	
	public static Signal FetchSignal(){
		Signal dummy;
		dummy = list.next;
		list.next = dummy.next;
		dummy.next = null;
		return dummy;
	}
}
